package com.gavin.ioc.controller;

import jakarta.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@RequestMapping("/prop")
@ResponseBody
@Controller
public class PropertiesController {
    @Value("${my.key}")
    private Integer myKey;

    @Value("${my.key2}")
    private Boolean myKey2;

    @RequestMapping("/read")
    public String readValue(){
        return "读取配置文件my.key:"+myKey;
    }

    @PostConstruct
    public void init(){
        System.out.println("mykey2:"+myKey2);
    }
}
